export default {
  data(){
    return{
      exitshow: false
    }
  },
  onLoad() {
    // this.IsExistPayPwd()
  },
  methods: {
    // 跳转页面
    goPage(url) {
      uni.navigateTo({
        url: url,
      })
    },

    //注销
    logOff() {
      uni.showModal({
        title: '提示',
        content: '注销账号不可逆，请确认是否注销账号？',
        confirmColor: '#FBB000',
        success: res => {
          if (res.confirm) {
            this.$store.commit('resetInfo')
            this.$store.commit('user/resetInfo')
            let promise = this.tim.logout()
            promise
              .then(res => {
                this.$store.commit('news/reset')
              })
              .catch(err => {
                console.log('注销失败')
              })
            uni.removeStorageSync('token')
            uni.removeStorageSync('userInfoDetail')
            uni.removeStorage({
              key: 'Ztc_B_USER_INFO',
              success: function (res) {
                uni.redirectTo({
                  url: '/pages_login/login/login',
                })
              },
            })
          }
        },
      })
    },

    //退出登录
    logout() {
      // #ifdef APP-PLUS
      // 更新用户推送设备
      this.$api.user.AddOrEditUniPush({
        type: 'logout',
        cid: plus.push.getClientInfo().clientid,
        platform: uni.getSystemInfoSync().platform,
     storeId: this.$store.state.userInfoDetail.store.storeId,
     phone: this.$store.state.user.userInfo.mobile
			}).then(res => {
        console.log(res)
      })
      // #endif
      this.$store.commit('resetInfo')
      this.$store.commit('user/resetInfo')
      let promise = this.tim.logout()
      promise
        .then(res => {
          this.$store.commit('news/reset')
        })
        .catch(err => {
          console.log('退出失败')
        })

      this.exitshow=false
      uni.removeStorageSync('token')
      uni.removeStorageSync('userInfoDetail')
      uni.removeStorage({
        key: 'Ztc_B_USER_INFO',
        success: function (res) {
          uni.redirectTo({
            url: '/pages_login/login/login',
          })
        },
      })
    },
    // //是否设置支付密码
    // async IsExistPayPwd() {
    //   try {
    //     const res = await this.$api.user.IsExistPayPwd()
    //     console.log(res)
    //   } catch (e) {
    //     console.log(e)
    //     //TODO handle the exception
    //   }
    // },
  },
}
